无法启动selenium。java中的WebDriver firefox在一个没有UI的盒子中
我有一个类似于:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
class Gecko {
...
FirefoxBinary ffB = new FirefoxBinary();
ffB.setEnvironmentProperty("DISPLAY", ":10");
...
options.setBinary(ffB);
WebDriver driver = new FirefoxDriver(options);
然后,我使用以下命令启动虚拟帧缓冲区:
Xvfb :10 -screen 0 1024x768x24 &
但当我使用Selenium时:
java -cp .:selenium-server-standalone-3.5.0.jar Gecko
以下问题显示:
1508364524466 geckodriver::marionette INFO Starting browser /usr/bin/firefox with args ["-marionette"]
Error: GDK_BACKEND does not match available displays
Exception in thread "main" org.openqa.selenium.WebDriverException: connection refused
哪一个可能是原因?用户权限?防火墙?当前框未安装任何桌面环境
# 1 楼答案
如果显示错误:GDK_后端与可用显示不匹配,请安装pyvirtualdisplay: